require File.dirname(__FILE__) + '/server'

server_id = ARGV[0]
script_id = ARGV[1]
task_name = ARGV[2]
user_name = ARGV[3]
password = ARGV[4]

script_path = 'c:\scripts\EBS\schedule_script.rb'
params = "/create /tn \"#{task_name}\" /tr \"ruby '#{script_path}' #{server_id} #{script_id}\"  /sc daily /st 02:00 /ru #{user_name} /rp #{password}"

tasks = `schtasks`

if !tasks.include? "#{task_name}"
  puts "adding task #{task_name}"
  `schtasks #{params}`
end

puts "running script"
server = Server.new
server.run_script server_id, script_id

puts "schedule script completed"